import requests

head = {
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36"
}

# 获取网页源码
resp = requests.get("https://www.baidu.com/", headers=head).text

# 写入文件中
with open("myBaidu.html", 'w', encoding= "utf-8") as f:
    f.write(resp)
print("over")
